    <script type="text/javascript">
         var i=3;
         document.cookie='variablephp='+i;
    </script>
    <?php 
         $var = $_COOKIE['variablephp'];
     ?>

  